<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>需要登录</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
            background: #f5f7fa;
            color: #333;
            line-height: 1.6;
            height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        
        .unauthorized-container {
            background: #fff;
            border-radius: 12px;
            padding: 48px 32px;
            box-shadow: 0 4px 20px rgba(0,0,0,0.1);
            text-align: center;
            max-width: 400px;
            width: 90%;
        }
        
        .icon {
            width: 64px;
            height: 64px;
            margin: 0 auto 24px;
            background: #e74c3c;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-size: 24px;
        }
        
        .title {
            font-size: 24px;
            font-weight: 600;
            color: #2c3e50;
            margin-bottom: 16px;
        }
        
        .message {
            color: #7f8c8d;
            margin-bottom: 32px;
            line-height: 1.6;
        }
        
        .actions {
            display: flex;
            flex-direction: column;
            gap: 12px;
        }
        
        .btn {
            padding: 12px 24px;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            font-size: 16px;
            text-decoration: none;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            transition: all 0.2s ease;
        }
        
        .btn-primary {
            background: #3498db;
            color: white;
        }
        
        .btn-primary:hover {
            background: #2980b9;
        }
        
        .btn-secondary {
            background: transparent;
            color: #7f8c8d;
            border: 1px solid #bdc3c7;
        }
        
        .btn-secondary:hover {
            background: #ecf0f1;
        }
        
        .project-info {
            background: #f8f9fa;
            border-radius: 6px;
            padding: 16px;
            margin-bottom: 24px;
            font-size: 14px;
        }
        
        .project-info strong {
            color: #2c3e50;
        }
    </style>
</head>
<body>
    <div class="unauthorized-container">
        <div class="icon">🔒</div>
        <h1 class="title">需要登录</h1>
        <p class="message">{{ message }}</p>
        
        <div class="project-info">
            <strong>项目 ID:</strong> {{ project_id }}<br>
            <strong>批次 ID:</strong> {{ batch_id }}
        </div>
        
        <div class="actions">
            <button onclick="requestLogin()" class="btn btn-primary">
                前往登录
            </button>
            <button onclick="closeWindow()" class="btn btn-secondary">
                关闭窗口
            </button>
        </div>
    </div>

    <script>
        // 全局配置
        window.EMBED_CONFIG = {
            batchId: '{{ batch_id }}',
            projectId: '{{ project_id }}',
            targetOrigin: 'https://yunzhishi.zzz4ai.com'
        };

        // 发送消息到父页面
        function sendMessage(type, payload) {
            const message = {
                type: type,
                payload: {
                    batchId: window.EMBED_CONFIG.batchId,
                    ...payload
                }
            };
            
            parent.postMessage(message, window.EMBED_CONFIG.targetOrigin);
        }

        // 请求登录
        function requestLogin() {
            sendMessage('PPT_LOGIN_REQUIRED', {
                projectId: window.EMBED_CONFIG.projectId,
                reason: 'unauthorized'
            });
        }

        // 关闭窗口
        function closeWindow() {
            sendMessage('PPT_CLOSE_REQUIRED', {
                projectId: window.EMBED_CONFIG.projectId,
                reason: 'unauthorized'
            });
        }

        // 页面加载完成后发送未授权消息
        document.addEventListener('DOMContentLoaded', function() {
            sendMessage('PPT_UNAUTHORIZED', {
                projectId: window.EMBED_CONFIG.projectId
            });
        });
    </script>
</body>
</html>
